<template>
	<view class="page_bg">
		<!-- #ifdef APP-PLUS -->
		<view class="status_bar">
			<view class="top_view"></view>
		</view>
		<!-- #endif -->
		<view class="top_nav">
			<image src="/static/local/3546451940011a031009b939a8b26314.png" class="image_1" @click="pageBack" />
			<view class="cate">详情</view>
		</view>
		<scroll-view scroll-y class="main u-skeleton">
			<view class="title u-skeleton-fillet">{{detail.title}}</view>
			<view class="time">
				<image src="/static/local/396f49ca8ad95619863067bb11d6cc28.png" class="image_4" />
				<text class="u-skeleton-fillet">发布时间：{{vk.pubfn.timeFormat(detail._add_time,"yyyy-MM-dd")}}</text>
			</view>
			<view class="u-skeleton-rect" :class="{content: loading}">
				<mp-html :content="detail.content"></mp-html>
			</view>
			<!-- 			<view class="images u-skeleton-fillet">
				<u-image :src="detail.avatar" :lazy-load="true" mode="aspectFill">
				</u-image>
			</view> -->
			<view class="empty"></view>
		</scroll-view>
		<u-skeleton :loading="loading" :animation="true" bgColor="#FFF"></u-skeleton>
	</view>
</template>

<script>
	var that; // 当前页面对象
	var vk; // vk依赖
	export default {
		data() {
			// 页面数据变量
			return {
				detail: {
					title: '占位',
					_add_time: '占位',
					content: '占位'
				},
				loading: true
			}
		},
		// 监听 - 页面每次【加载时】执行(如：前进)
		onLoad(options = {}) {
			that = this;
			vk = that.vk;
			that.init(options)
		},
		// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快，会在页面进入动画完成前触发
		onReady() {},
		// 监听 - 页面每次【显示时】执行(如：前进和返回) (页面每次出现在屏幕上都触发，包括从下级页面点返回露出当前页面)
		onShow() {},
		// 监听 - 页面每次【隐藏时】执行(如：返回)
		onHide() {},
		// 函数
		methods: {
			// 页面数据初始化函数
			init(options) {
				this.getNews(options.id)
			},
			pageBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			getNews(id) {
				vk.callFunction({
					url: 'client/articles/pub/getNewsDetail',

					data: {
						_id: id,
						need_user_info: true
					},
					success(res) {
						that.detail = res.data
						that.loading = false
					}
				});
			}
		},
	}
</script>

<style lang="scss" scoped>
	.page_bg {
		background-color: #ffffff;
		width: 100%;
		height: 100vh;
		overflow-y: auto;
	}

	.top_nav {
		padding-bottom: 24rpx;
		color: rgb(51, 51, 51);
		font-size: 34rpx;
		line-height: 41rpx;
		white-space: nowrap;
		background-color: rgb(255, 255, 255);
		height: 88rpx;
		position: relative;
		box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.1);

		.image_1 {
			left: 21rpx;
			top: 27rpx;
			width: 19rpx;
			height: 35rpx;
			position: absolute;
		}

		.cate {
			width: 100%;
			padding: 20rpx 0;
			color: rgb(51, 51, 51);
			font-size: 34rpx;
			font-weight: 500;
			line-height: 41rpx;
			white-space: nowrap;
			text-align: center;
		}
	}

	.main {
		padding: 0 20rpx;
		width: 100%;
		height: calc(100vh - 168rpx);
		box-sizing: border-box;

		.title {
			font-size: 40rpx;
			font-weight: bold;
			line-height: 60rpx;
			color: #333333;
			margin: 30rpx 0 20rpx;
		}

		.time {
			font-size: 24rpx;
			font-weight: 500;
			line-height: 33rpx;
			color: #999999;
			display: flex;
			align-items: center;
			margin-bottom: 20rpx;

			.image_4 {
				width: 26rpx;
				height: 26rpx;
				margin-right: 12rpx;
			}
		}

		.content {
			min-height: 40vh;
		}

		.images {
			margin-top: 30rpx;
			width: 32%;
			height: 0;
			padding-top: 32%;
			position: relative;
			border-radius: 10rpx;
			overflow: hidden;

			.u-image {
				position: absolute;
				top: 0;
				left: 0;
				height: 100% !important;
			}
		}

		.empty {
			height: 80rpx;
		}
	}
</style>